<template>
	<view class="gl-container">
		<swiper class="gl-page-swiper" :current="currentIndex" :disable-touch="true" :style="{height:swiperH+'px'}"
			@change="pageChange">
			<swiper-item>
				<subChainListVue @navEvent="navInfoEvent"></subChainListVue>
			</swiper-item>
			<swiper-item>
				<subChainInfoVue ref="subChainInfoVue" @navIndex="()=>{this.currentIndex = 0}"></subChainInfoVue>
			</swiper-item>
		</swiper>
	</view>
</template>

<script>
	import subChainListVue from './sub-chain-list.vue';
	import subChainInfoVue from './sub-chain-info.vue';
	export default {
		data() {
			return {
				swiperH: 0, // swiper高度
				name: 'chainMainVue',
				sConf: getApp().globalData,
				currentIndex: 0,
			}
		},
		mounted() {
			let window = uni.getWindowInfo();
			this.designLayout(window.windowHeight);
		},
		components: {
			subChainListVue,
			subChainInfoVue
		},
		methods: {
			/**
			 * 滑动换页回调
			 */
			pageChange(e) {
				console.log('pageChange', e.detail.current);
				// uni.setStorageSync('curSubTab', e.detail.current);
				this.$emit('subTabChange', e.detail.current)
			},
			designLayout(wh) {
				this.$nextTick(() => {
					const query = uni.createSelectorQuery().in(this);
					query.select('.gl-page-swiper').boundingClientRect();
					query.exec((res) => {
						this.swiperH = wh - Math.ceil(res[0].top) - 10 - 10;
					});
				})
			},
			/**
			 * 切换到次页
			 */
			navInfoEvent(e) {
				console.log('navInfoEvent', e);
				this.$refs.subChainInfoVue.loadDefData(e)
				this.currentIndex = 1
			},
		}
	}
</script>

<style lang="scss" scoped>

</style>